/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.testis.orm.refinedclasses;

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;

import org.testis.orm.classes.T_bed_testpc;
import org.testis.utils.middleware.TestPcDataHandler;

/**
 * 
 * @author selcuk
 */
public class TestPcRefined extends TestBedItem {

    private T_bed_testpc m_reference;

    public TestPcRefined(T_bed_testpc reference) {
	super();
	setReference(reference);
    }

    public int getId() {
	return m_reference.getId();
    }

    public String getName() {
	return m_reference.getName();
    }

    private void setReference(T_bed_testpc reference) {
	if (reference == null) {
	    throw new NullPointerException();
	}
	m_reference = reference;
    }

    @Override
    public String toString() {
	return getName();
    }

    @Override
    public String getTypeName() {
	return "TestPc";
    }

    public static TestPcRefined[] getTestPcArray() {
	Collection coll = TestPcDataHandler.newInstance().getTestPCs();
	TestPcRefined[] result = new TestPcRefined[coll.size()];
	int idx = 0;
	for (Iterator it = coll.iterator(); it.hasNext(); idx++) {
	    T_bed_testpc ref = (T_bed_testpc) it.next();
	    result[idx] = new TestPcRefined(ref);
	}
	return result;
    }

    public static LinkedList<TestPcRefined> getTestPcList() {
	TestPcRefined[] arr = getTestPcArray();
	LinkedList<TestPcRefined> result = new LinkedList<TestPcRefined>();
	for (int i = 0; i < arr.length; i++) {
	    result.add(arr[i]);
	}
	return result;
    }

    public static HashMap getTestPcMap() {
	TestPcRefined[] arr = getTestPcArray();
	HashMap result = new HashMap();
	for (int i = 0; i < arr.length; i++) {
	    result.put(arr[i].getId(), arr[i]);
	}
	return result;
    }
}
